﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.BIZ;

namespace AnyOffice.general.hrms
{
    public partial class detail : ModulePage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                int hrmsId = (Request.QueryString["hrms_id"] == null) ? 0 : Convert.ToInt32(Request.QueryString["hrms_id"].ToString());
                DataTable table = new HrmsDao().SelectByHrmsId(base.Conn, hrmsId);
                if (table.Rows.Count > 0)
                {
                    this.litUserName.Text = table.Rows[0]["UserName"].ToString();
                    this.litNumber.Text = (table.Rows[0]["Number"] != DBNull.Value) ? table.Rows[0]["Number"].ToString() : "";
                    if (Convert.ToInt32(table.Rows[0]["DeptId"].ToString()) != -1)
                    {
                        DataTable table2 = new DepartmentDao().SelectByDeptId(base.Conn, Convert.ToInt32(table.Rows[0]["DeptId"].ToString()));
                        if (table2.Rows.Count > 0)
                        {
                            this.litDeptName.Text = table2.Rows[0]["DeptName"].ToString();
                        }
                    }
                    else
                    {
                        this.litDeptName.Text = "离校人员/外部人员";
                    }
                    if (table.Rows[0]["Photo"] != DBNull.Value)
                    {
                        this.litPhoto.Text = "<a href=\"photo.aspx?hrms_id=" + hrmsId.ToString() + "\" target=\"_blank\" title=\"点击查看放大图片\"><img src=\"photo.aspx?hrms_id=" + hrmsId.ToString() + "\" width=\"100\" border=\"1\"></a>";
                    }
                    if (table.Rows[0]["Sex"] != DBNull.Value)
                    {
                        this.litSex.Text = Convert.ToBoolean(table.Rows[0]["Sex"].ToString()) ? "男" : "女";
                    }
                    this.litBirthday.Text = (table.Rows[0]["Birthday"] != DBNull.Value) ? Convert.ToDateTime(table.Rows[0]["Birthday"].ToString()).ToString("d") : "";
                    this.litNation.Text = (table.Rows[0]["Nation"] != DBNull.Value) ? table.Rows[0]["Nation"].ToString() : "";
                    this.litCardNo.Text = (table.Rows[0]["CardNo"] != DBNull.Value) ? table.Rows[0]["CardNo"].ToString() : "";
                    if (table.Rows[0]["Marry"] != DBNull.Value)
                    {
                        this.litMarry.Text = table.Rows[0]["Marry"].ToString();
                    }
                    this.litNativePlace.Text = (table.Rows[0]["NativePlace"] != DBNull.Value) ? table.Rows[0]["NativePlace"].ToString() : "";
                    this.litHukouPlace.Text = (table.Rows[0]["HukouPlace"] != DBNull.Value) ? table.Rows[0]["HukouPlace"].ToString() : "";
                    if (table.Rows[0]["Education"] != DBNull.Value)
                    {
                        this.litEducation.Text = table.Rows[0]["Education"].ToString();
                    }
                    this.litSpeciallity.Text = (table.Rows[0]["Speciallity"] != DBNull.Value) ? table.Rows[0]["Speciallity"].ToString() : "";
                    this.litSchool.Text = (table.Rows[0]["School"] != DBNull.Value) ? table.Rows[0]["School"].ToString() : "";
                    this.litWorkDate.Text = (table.Rows[0]["WorkDate"] != DBNull.Value) ? Convert.ToDateTime(table.Rows[0]["WorkDate"].ToString()).ToString("d") : "";
                    this.litJoinDate.Text = (table.Rows[0]["JoinDate"] != DBNull.Value) ? Convert.ToDateTime(table.Rows[0]["JoinDate"].ToString()).ToString("d") : "";
                    this.litContractType.Text = (table.Rows[0]["ContractType"] != DBNull.Value) ? table.Rows[0]["ContractType"].ToString() : "";
                    this.litPost.Text = (table.Rows[0]["Post"] != DBNull.Value) ? table.Rows[0]["Post"].ToString() : "";
                    this.litTechPost.Text = (table.Rows[0]["TechPost"] != DBNull.Value) ? table.Rows[0]["TechPost"].ToString() : "";
                    if (table.Rows[0]["Politics"] != DBNull.Value)
                    {
                        this.litPolitics.Text = table.Rows[0]["Politics"].ToString();
                    }
                    this.litHomeAddr.Text = (table.Rows[0]["HomeAddr"] != DBNull.Value) ? table.Rows[0]["HomeAddr"].ToString() : "";
                    this.litHomeTel.Text = (table.Rows[0]["HomeTel"] != DBNull.Value) ? table.Rows[0]["HomeTel"].ToString() : "";
                    this.litEmail.Text = (table.Rows[0]["Email"] != DBNull.Value) ? table.Rows[0]["Email"].ToString() : "";
                    if ((table.Rows[0]["ContractDate1"] != DBNull.Value) && (table.Rows[0]["ContractDate2"] != DBNull.Value))
                    {
                        this.litContractDate.Text = Convert.ToDateTime(table.Rows[0]["ContractDate1"].ToString()).ToString("d") + " 至 " + Convert.ToDateTime(table.Rows[0]["ContractDate2"].ToString()).ToString("d");
                    }
                    if (table.Rows[0]["LeaveType"] != DBNull.Value)
                    {
                        this.litLeaveType.Text = table.Rows[0]["LeaveType"].ToString();
                    }
                    this.litPostChange.Text = (table.Rows[0]["PostChange"] != DBNull.Value) ? table.Rows[0]["PostChange"].ToString() : "";
                    this.litPostChange.Text = this.litPostChange.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litEdu.Text = (table.Rows[0]["Edu"] != DBNull.Value) ? table.Rows[0]["Edu"].ToString() : "";
                    this.litEdu.Text = this.litEdu.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litResume.Text = (table.Rows[0]["Resume"] != DBNull.Value) ? table.Rows[0]["Resume"].ToString() : "";
                    this.litResume.Text = this.litResume.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litSociaty.Text = (table.Rows[0]["Sociaty"] != DBNull.Value) ? table.Rows[0]["Sociaty"].ToString() : "";
                    this.litSociaty.Text = this.litSociaty.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litReward.Text = (table.Rows[0]["Reward"] != DBNull.Value) ? table.Rows[0]["Reward"].ToString() : "";
                    this.litReward.Text = this.litReward.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litCertificate.Text = (table.Rows[0]["Certificate"] != DBNull.Value) ? table.Rows[0]["Certificate"].ToString() : "";
                    this.litCertificate.Text = this.litCertificate.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litTrain.Text = (table.Rows[0]["Train"] != DBNull.Value) ? table.Rows[0]["Train"].ToString() : "";
                    this.litTrain.Text = this.litTrain.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litSurety.Text = (table.Rows[0]["Surety"] != DBNull.Value) ? table.Rows[0]["Surety"].ToString() : "";
                    this.litSurety.Text = this.litSurety.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litContract.Text = (table.Rows[0]["Contract"] != DBNull.Value) ? table.Rows[0]["Contract"].ToString() : "";
                    this.litContract.Text = this.litContract.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litInsure.Text = (table.Rows[0]["Insure"] != DBNull.Value) ? table.Rows[0]["Insure"].ToString() : "";
                    this.litInsure.Text = this.litInsure.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    this.litBodyExamim.Text = (table.Rows[0]["BodyExamim"] != DBNull.Value) ? table.Rows[0]["BodyExamim"].ToString() : "";
                    this.litBodyExamim.Text = this.litBodyExamim.Text.Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    if (table.Rows[0]["Memo"] != DBNull.Value)
                    {
                        this.litMemo.Text = table.Rows[0]["Memo"].ToString().Replace("\r\n", "<br>").Replace(" ", "&nbsp;");
                    }
                    string attachmentId = (table.Rows[0]["AttachmentId"] != DBNull.Value) ? table.Rows[0]["AttachmentId"].ToString() : "";
                    if ((this.litAttachment.Text = AttachmentBiz.Display(base.Conn, attachmentId)) == string.Empty)
                    {
                        this.litAttachment.Text = "无";
                    }
                }
            }
        } 

    }
}
